package salary.calculation.common.response;


import salary.calculation.common.enumerate.CommonResponseEnum;
import salary.calculation.common.enumerate.IResponseEnum;

import java.io.Serializable;

public class BaseResponse implements Serializable {
    /**
     * 返回码
     */
    private int code;
    /**
     * 返回消息
     */
    private String msg;

    public BaseResponse() {
        this.code = CommonResponseEnum.SUCCESS.getCode();
        this.msg = CommonResponseEnum.SUCCESS.getMsg();
    }

    public BaseResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public BaseResponse(IResponseEnum responseEnum) {
        this.code = responseEnum.getCode();
        this.msg = responseEnum.getMsg();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static BaseResponse newInstance() {
        return new BaseResponse();
    }

    public static BaseResponse newInstance(IResponseEnum responseEnum) {
        return new BaseResponse(responseEnum);
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }
}
